﻿using Iservices;
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Model;
using EFEntity;
using System.Linq;
using Microsoft.Data.SqlClient;
using AutoMapper;
using Microsoft.EntityFrameworkCore;
namespace Services
{
   public class config_file_second_kindServices:Iconfig_file_second_kindServices
    {
        private readonly MyDbContext myDbContext;
        private readonly IMapper mapper;
        public config_file_second_kindServices(MyDbContext myDbContext, IMapper mapper)
        {
            this.myDbContext = myDbContext;
            this.mapper = mapper;
        }

        public async Task<List<config_file_second_kind>> selectAll()
        {
            List<Econfig_file_second_kind> list = new List<Econfig_file_second_kind>();
            await Task.Run(() =>
            {
                list = myDbContext.config_file_second_kind.ToList();

            });
            //Automap
            List<config_file_second_kind> list2 = new List<config_file_second_kind>();
            foreach (Econfig_file_second_kind item in list)
            {
                config_file_second_kind t = new config_file_second_kind()
                {
                    fsk_id = item.fsk_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    second_kind_id = item.second_kind_id,
                    second_kind_name = item.second_kind_name,
                    second_salary_id = item.second_salary_id,
                    second_sale_id = item.second_sale_id,
                };
                list2.Add(t);
            }
            return list2;
        }

        async Task<List<config_file_second_kind>> Iconfig_file_second_kindServices.secondfristSelect()
        {
            List<Econfig_file_second_kind> list = new List<Econfig_file_second_kind>();
            await Task.Run(() =>
            {
                list = myDbContext.config_file_second_kind.ToList();

            });
            //Automap
            List<config_file_second_kind> list2 = new List<config_file_second_kind>();
            foreach (Econfig_file_second_kind item in list)
            {
                config_file_second_kind t = new config_file_second_kind()
                {
                    fsk_id = item.fsk_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    second_kind_id = item.second_kind_id,
                    second_kind_name = item.second_kind_name,
                    second_salary_id = item.second_salary_id,
                    second_sale_id = item.second_sale_id,
                };
                list2.Add(t);
            }
            return list2;
        }
    }
}
